package com.atguigu5.arrays;

import java.util.Arrays;

/**
 * ClassName: ArrayTest
 * Package: com.atguigu5.arrays
 * Description:
 *
 * @Author BuTang
 * @Create 2023/2/24 22:05
 * @Version 1.0
 */
public class ArrayTest {
    public static void main(String[] args) {

        //equals比较两个数组的元素是否相等
        int[] arr1 = new int[]{1,2,3};
        int[] arr2 =new int[]{1,2,3};
        boolean isEquals = Arrays.equals(arr1 ,arr2);
        System.out.println(isEquals);

        //2.String toString（int[] a）;输出元素的信息
        System.out.println(Arrays.toString(arr1));

        //3,void fill(int[] a ,int val)
        Arrays.fill(arr1,10);
        System.out.println(Arrays.toString(arr1));

        //4.void sort(int[] a)使用快速排序算法实现排序
        int[] arr = new int[]{34,43,3,2,65,7,34,5,76,34,67};
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));

        //5.int binarySeach(int[] a, int key) :二分查找
        //使用前提：当前数组必须是有序的
        int idex = Arrays.binarySearch(arr,15);
        if(idex >=0 ){
            System.out.println("找到啦");


        }
    }
}
